package cn.okcmd.base;

import lombok.extern.slf4j.Slf4j;

import java.util.*;

/**
 * create by caoqg on 2021/7/17
 * 功能说明: 查看系统所有属性 和环境变量
 */
@Slf4j
public class TestAllSysProp {
    public static void main(String[] args) {
        Properties properties = System.getProperties();
        List<Map.Entry> propList = new ArrayList<>(properties.entrySet());
        printList("系统属性", propList);
        Map<String, String> envs = System.getenv();
        List<Map.Entry> envList = new ArrayList<>(envs.entrySet());
        printList("环境变量", envList);
    }

    public static void printList(String type,List<Map.Entry> list){
        log.info("======={}=====",type);
        for (int i = 0; i < list.size(); i++) {
            Map.Entry entry = list.get(i);
            log.info("type:{}, index:{}, key:[{}], value:[{}]", type, i + 1, entry.getKey(), entry.getValue());
        }
    }
}
